package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.businessReportPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * ClassName:businessReportMapp
 * Description:
 *
 * @Author 赵永峰
 * @Create 2025/10/23 15:17
 * @Version 1.0
 */
@Mapper
public interface businessReportMapp {
    //辅助函数：对业务汇报中，根据某一个字段查询等于某一值的函数
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_business_report where ${fieldName}=#{fieldVal}")
    List<businessReportPojo> inquiryOneFiled(String fieldName, String fieldVal);
    //辅助函数：对业务汇报中，插入一条数据，所有字段都插入
    @DS("newMscLowCodeFormal")
    @Insert("INSERT INTO ddm_business_report ("
            + "id, "
            + "create_time, "
            + "update_time, "
            + "creator, "
            + "process_status, "
            + "sys_update_user, "
            + "sys_audit_user, "
            + "sys_audit_time, "
            + "sys_deleted, "
            + "business, "
            + "management_goal, "
            + "system_require, "
            + "key_analysis, "
            + "sub_business_1, sign_sub_business_1, "
            + "sub_business_2, sign_sub_business_2, "
            + "sub_business_3, sign_sub_business_3, "
            + "sub_business_4, sign_sub_business_4, "
            + "sub_business_5, sign_sub_business_5, "
            + "sub_business_6, sign_sub_business_6, "
            + "sub_business_7, sign_sub_business_7, "
            + "sub_business_8, sign_sub_business_8, "
            + "sub_business_9, sign_sub_business_9, "
            + "sub_business_10, sign_sub_business_10, "
            + "sub_business_11, sign_sub_business_11, "
            + "sub_business_12, sign_sub_business_12, "
            + "sub_business_13, sign_sub_business_13, "
            + "sub_business_14, sign_sub_business_14, "
            + "sub_business_15, sign_sub_business_15"
            + ") VALUES ("
            + "#{id}, "
            + "#{create_time}, "
            + "#{update_time}, "
            + "#{creator}, "
            + "#{process_status}, "
            + "#{sys_update_user}, "
            + "#{sys_audit_user}, "
            + "#{sys_audit_time}, "
            + "#{sys_deleted}, "
            + "#{business}, "
            + "#{management_goal}, "
            + "#{system_require}, "
            + "#{key_analysis}, "
            + "#{sub_business_1}, #{sign_sub_business_1}, "
            + "#{sub_business_2}, #{sign_sub_business_2}, "
            + "#{sub_business_3}, #{sign_sub_business_3}, "
            + "#{sub_business_4}, #{sign_sub_business_4}, "
            + "#{sub_business_5}, #{sign_sub_business_5}, "
            + "#{sub_business_6}, #{sign_sub_business_6}, "
            + "#{sub_business_7}, #{sign_sub_business_7}, "
            + "#{sub_business_8}, #{sign_sub_business_8}, "
            + "#{sub_business_9}, #{sign_sub_business_9}, "
            + "#{sub_business_10}, #{sign_sub_business_10}, "
            + "#{sub_business_11}, #{sign_sub_business_11}, "
            + "#{sub_business_12}, #{sign_sub_business_12}, "
            + "#{sub_business_13}, #{sign_sub_business_13}, "
            + "#{sub_business_14}, #{sign_sub_business_14}, "
            + "#{sub_business_15}, #{sign_sub_business_15}"
            + ")")
    void insertOne(businessReportPojo pojo);
    //辅助函数：向业务汇报的表中根据id，修改一行数据
    @DS("newMscLowCodeFormal")
    @Update("UPDATE ddm_business_report SET " +
            "create_time = #{create_time}, " +
            "update_time = NOW(), " +  // 自动设置更新时间
            "creator = #{creator}, " +
            "process_status = #{process_status}, " +
            "sys_update_user = #{sys_update_user}, " +
            "sys_audit_user = #{sys_audit_user}, " +
            "sys_audit_time = #{sys_audit_time}, " +
            "sys_deleted = #{sys_deleted}, " +
            "business = #{business}, " +
            "management_goal = #{management_goal}, " +
            "system_require = #{system_require}, " +
            "key_analysis = #{key_analysis}, " +
            "sub_business_1 = #{sub_business_1}, sign_sub_business_1 = #{sign_sub_business_1}, " +
            "sub_business_2 = #{sub_business_2}, sign_sub_business_2 = #{sign_sub_business_2}, " +
            "sub_business_3 = #{sub_business_3}, sign_sub_business_3 = #{sign_sub_business_3}, " +
            "sub_business_4 = #{sub_business_4}, sign_sub_business_4 = #{sign_sub_business_4}, " +
            "sub_business_5 = #{sub_business_5}, sign_sub_business_5 = #{sign_sub_business_5}, " +
            "sub_business_6 = #{sub_business_6}, sign_sub_business_6 = #{sign_sub_business_6}, " +
            "sub_business_7 = #{sub_business_7}, sign_sub_business_7 = #{sign_sub_business_7}, " +
            "sub_business_8 = #{sub_business_8}, sign_sub_business_8 = #{sign_sub_business_8}, " +
            "sub_business_9 = #{sub_business_9}, sign_sub_business_9 = #{sign_sub_business_9}, " +
            "sub_business_10 = #{sub_business_10}, sign_sub_business_10 = #{sign_sub_business_10}, " +
            "sub_business_11 = #{sub_business_11}, sign_sub_business_11 = #{sign_sub_business_11}, " +
            "sub_business_12 = #{sub_business_12}, sign_sub_business_12 = #{sign_sub_business_12}, " +
            "sub_business_13 = #{sub_business_13}, sign_sub_business_13 = #{sign_sub_business_13}, " +
            "sub_business_14 = #{sub_business_14}, sign_sub_business_14 = #{sign_sub_business_14}, " +
            "sub_business_15 = #{sub_business_15}, sign_sub_business_15 = #{sign_sub_business_15}, " +
            "index_name = #{index_name} " +
            "WHERE id = #{id}")
    void editOneRowById(businessReportPojo pojo);
}
